package com.study.innerclass4;

public class Test2 {
    public static void main(String[] args) {
        //匿名类可以更方便的创建出一个子类对象

/*        Swimming s = new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生游泳贼溜🏊‍");
            }
        };*/
        //匿名类通常作为一个参数传给方法
        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生游泳贼溜🏊‍");
            }
        });
    }
    public static void go(Swimming s){
        System.out.println("开始");
        s.swim();
        System.out.println("结束");
    }
}

interface Swimming{
    void swim();
}
